import {UPDATE_ARTICLE_LIST, UPDATE_ARTICLE_CATES, ADD_ARTICLE,DEL_ARTICLE, ARTICLE_INFO} from '@/store2/reducersTypes'
const initState = {
  articleList: [],
  articleCates: [],
  done: 0,
  delId: '',
  info: {}
}

export default (state=initState, actions) => {
  const newState = JSON.parse(JSON.stringify(state))
  switch (actions.type) {
    case UPDATE_ARTICLE_LIST:
      newState.articleList = actions.payload
      break;
    case UPDATE_ARTICLE_CATES:
      newState.articleCates = actions.payload
      break;
    case ADD_ARTICLE:
      newState.done++
      break;
    case DEL_ARTICLE:
      console.log(actions);
      newState.delId = actions.payload
      break;
    case ARTICLE_INFO: 
    console.log(actions.payload);
      newState.info = actions.payload
      break;
    default:
      break;
  }
  return newState
} 